package com.sg.service.biz.pbff.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.pbff.req.BffImplementCleaningWasteEvaluationDataReqDto;
import com.sg.dto.biz.pbff.req.BffImplementPrivatizationAndSeparationDataReqDto;
import com.sg.dto.biz.pbff.res.BffImplementCleaningWasteEvaluationDataRespDto;
import com.sg.dto.biz.pbff.res.BffImplementPrivatizationAndSeparationDataRespDto;
import com.sg.dto.integration.framework.QuerySpaceListReqDto;
import com.sg.dto.integration.framework.QuerySpaceListRespDto;
import com.sg.dto.integration.operation.ImplementCleaningWasteEvaluationDataComReqDto;
import com.sg.dto.integration.operation.ImplementCleaningWasteEvaluationDataComRespDto;
import com.sg.dto.integration.operation.ImplementPrivatizationAndSeparationDataComReqDto;
import com.sg.dto.integration.operation.ImplementPrivatizationAndSeparationDataComRespDto;
import com.sg.service.biz.pbff.OperationsDeploymentService;
import com.wicket.okrapp.integration.OperationsDeploymentService;
import com.wicket.okrframework.integration.BaseService;
import com.wicket.okroperation.integration.OperationsDeploymentService;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;
//import com.wicket.okrcomponent.integration.dto.ImplementPrivatizationAndSeparationDataComRespDto;
//import com.wicket.okrcomponent.integration.dto.ImplementPrivatizationAndSeparationDataComReqDto;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class OperationsDeploymentServiceImpl
        implements OperationsDeploymentService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    com.sg.service.biz.framework.BaseService fwBaseBaseClient;


    @Resource
    com.sg.service.biz.app.OperationsDeploymentService fwAppOperationsDeploymentClient;
    @Resource
    com.sg.service.biz.operation.OperationsDeploymentService fwOperationOperationsDeploymentClient;

    /**
     * B6执行私有化分离数据(管理)[7201]
     * gen by moon at 9/14/2023, 11:38:57 PM
     */
    @Trace(operationName = "B6执行私有化分离数据(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffImplementPrivatizationAndSeparationDataRespDto implementPrivatizationAndSeparationData(BffImplementPrivatizationAndSeparationDataReqDto reqDto) {


        QuerySpaceListRespDto querySpaceListRespDto_1 = null;
        //步骤0: D1-2查询空间列表 - querySpaceList
        QuerySpaceListRespDto querySpaceListRespDto = null;
        QuerySpaceListReqDto querySpaceListReqDto = new QuerySpaceListReqDto();
        if (reqDto != null) {
            querySpaceListReqDto.setPlatformType(reqDto.getPlatformType());//SimpleFieldAssign//sourceId:1120314_1
        }

        /*D1-2查询空间列表[434]   */

        querySpaceListRespDto = fwBaseBaseClient.querySpaceList(querySpaceListReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        querySpaceListRespDto_1 = querySpaceListRespDto;

//步骤1: D6执行私有化分离数据(公共) - implementPrivatizationAndSeparationDataCom
        ImplementPrivatizationAndSeparationDataComRespDto implementPrivatizationAndSeparationDataComRespDto = null;
        if (querySpaceListRespDto != null) {
            com.wicket.okroperation.integration.dto.ImplementPrivatizationAndSeparationDataComReqDto implementPrivatizationAndSeparationDataComReqDto = new ImplementPrivatizationAndSeparationDataComReqDto();
            if (reqDto != null) {
                implementPrivatizationAndSeparationDataComReqDto.setDatabaseIpAdress(reqDto.getDatabaseIpAdress());//SimpleFieldAssign//sourceId:1120669_1
                implementPrivatizationAndSeparationDataComReqDto.setDatabaseport(reqDto.getDatabaseport());//SimpleFieldAssign//sourceId:1120670_1
                implementPrivatizationAndSeparationDataComReqDto.setDatabaseName(reqDto.getDatabaseName());//SimpleFieldAssign//sourceId:1120696_1
                implementPrivatizationAndSeparationDataComReqDto.setDatabaseAccount(reqDto.getDatabaseAccount());//SimpleFieldAssign//sourceId:1120671_1
                implementPrivatizationAndSeparationDataComReqDto.setDatabasePassword(reqDto.getDatabasePassword());//SimpleFieldAssign//sourceId:1120672_1
                implementPrivatizationAndSeparationDataComReqDto.setOperationSeparatedDataId(reqDto.getOperationSeparatedDataId());//SimpleFieldAssign//sourceId:1036591_1
                implementPrivatizationAndSeparationDataComReqDto.setToolTableEncryptionName(reqDto.getToolTableEncryptionName());//SimpleFieldAssign//sourceId:1036586_1
                implementPrivatizationAndSeparationDataComReqDto.setEntityName(reqDto.getEntityName());//SimpleFieldAssign//sourceId:1036590_1
                implementPrivatizationAndSeparationDataComReqDto.setTenantSpaceId(reqDto.getTenantSpaceId());//SimpleFieldAssign//sourceId:1120363_1
            }
            if (querySpaceListRespDto != null && querySpaceListRespDto.getSpaceList() != null && !CollectionUtil.isEmpty(querySpaceListRespDto.getSpaceList())) {
                implementPrivatizationAndSeparationDataComReqDto.setSpaceList(querySpaceListRespDto.getSpaceList().stream().map(item -> item.getSpaceId())
                        .collect(Collectors.toList()));/*list-to-strings*///sourceId:1120364_1
            }

            /*D6执行私有化分离数据(公共)[7193]   */
            Assert.isNull(implementPrivatizationAndSeparationDataComReqDto.getOperationSeparatedDataId(), "B6执行私有化分离数据(管理)-D6执行私有化分离数据(公共)-分离数据表主键ID不能为空", false);
            Assert.isNull(implementPrivatizationAndSeparationDataComReqDto.getToolTableEncryptionName(), "B6执行私有化分离数据(管理)-D6执行私有化分离数据(公共)-设计工具加密表名不能为空", false);
            Assert.isNull(implementPrivatizationAndSeparationDataComReqDto.getEntityName(), "B6执行私有化分离数据(管理)-D6执行私有化分离数据(公共)-内容表主键字段英文名不能为空", false);
            Assert.isNull(implementPrivatizationAndSeparationDataComReqDto.getTenantSpaceId(), "B6执行私有化分离数据(管理)-D6执行私有化分离数据(公共)-租户空间ID不能为空", false);
            implementPrivatizationAndSeparationDataComRespDto = fwOperationOperationsDeploymentClient.implementPrivatizationAndSeparationDataCom(implementPrivatizationAndSeparationDataComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        }

        BffImplementPrivatizationAndSeparationDataRespDto retData = new BffImplementPrivatizationAndSeparationDataRespDto();
        if (querySpaceListRespDto_1 != null && querySpaceListRespDto_1.getSpaceList() != null && !CollectionUtil.isEmpty(querySpaceListRespDto_1.getSpaceList())) {
            retData.setPrivatizationAndSeparationDataSpaceList(querySpaceListRespDto_1.getSpaceList().stream().map(item -> item.getSpaceId())
                    .collect(Collectors.toList()));/*list-to-strings*///sourceId:1120368_1
        }


        return retData;
    }

    /**
     * B6执行清洗垃圾评价数据(管理)[7198]
     * gen by moon at 9/13/2023, 10:45:07 PM
     */
    @Trace(operationName = "B6执行清洗垃圾评价数据(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffImplementCleaningWasteEvaluationDataRespDto implementCleaningWasteEvaluationData(BffImplementCleaningWasteEvaluationDataReqDto reqDto) {


        ImplementCleaningWasteEvaluationDataComRespDto implementCleaningWasteEvaluationDataComRespDto_1 = null;
//步骤0: D6执行清洗垃圾评价数据(公共) - implementCleaningWasteEvaluationDataCom
        com.wicket.okroperation.integration.dto.ImplementCleaningWasteEvaluationDataComRespDto implementCleaningWasteEvaluationDataComRespDto = null;
        com.wicket.okroperation.integration.dto.ImplementCleaningWasteEvaluationDataComReqDto implementCleaningWasteEvaluationDataComReqDto = new ImplementCleaningWasteEvaluationDataComReqDto();
        if (reqDto != null) {
            implementCleaningWasteEvaluationDataComReqDto.setTureOrFalse(reqDto.getTureOrFalse());//SimpleFieldAssign//sourceId:1120417_1
            implementCleaningWasteEvaluationDataComReqDto.setToolTableEncryptionName(reqDto.getToolTableEncryptionName());//SimpleFieldAssign//sourceId:1035823_1
            implementCleaningWasteEvaluationDataComReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1035824_1
            implementCleaningWasteEvaluationDataComReqDto.setThemeContentId(reqDto.getThemeContentId());//SimpleFieldAssign//sourceId:1035825_1
            implementCleaningWasteEvaluationDataComReqDto.setCycleDataObjId(reqDto.getCycleDataObjId());//SimpleFieldAssign//sourceId:1035826_1
            implementCleaningWasteEvaluationDataComReqDto.setCreateInductionId(reqDto.getCreateInductionId());//SimpleFieldAssign//sourceId:1120418_1
            implementCleaningWasteEvaluationDataComReqDto.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1120419_1
            implementCleaningWasteEvaluationDataComReqDto.setAppId(reqDto.getAppId());//SimpleFieldAssign//sourceId:1120420_1
        }

        /*D6执行清洗垃圾评价数据(公共)[7192]   */
        Assert.isNull(implementCleaningWasteEvaluationDataComReqDto.getTureOrFalse(), "B6执行清洗垃圾评价数据(管理)-D6执行清洗垃圾评价数据(公共)-是否不能为空", false);
        Assert.isNull(implementCleaningWasteEvaluationDataComReqDto.getToolTableEncryptionName(), "B6执行清洗垃圾评价数据(管理)-D6执行清洗垃圾评价数据(公共)-设计工具加密表名不能为空", false);
        Assert.isNull(implementCleaningWasteEvaluationDataComReqDto.getCreateInductionId(), "B6执行清洗垃圾评价数据(管理)-D6执行清洗垃圾评价数据(公共)-创建人就职记录ID不能为空", false);
        Assert.isNull(implementCleaningWasteEvaluationDataComReqDto.getSpaceId(), "B6执行清洗垃圾评价数据(管理)-D6执行清洗垃圾评价数据(公共)-创建于空间ID不能为空", false);
        Assert.isNull(implementCleaningWasteEvaluationDataComReqDto.getAppId(), "B6执行清洗垃圾评价数据(管理)-D6执行清洗垃圾评价数据(公共)-创建于联盟应用ID不能为空", false);
        implementCleaningWasteEvaluationDataComRespDto = fwOperationOperationsDeploymentClient.implementCleaningWasteEvaluationDataCom(implementCleaningWasteEvaluationDataComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        implementCleaningWasteEvaluationDataComRespDto_1 = implementCleaningWasteEvaluationDataComRespDto;

        BffImplementCleaningWasteEvaluationDataRespDto retData = new BffImplementCleaningWasteEvaluationDataRespDto();
        if (implementCleaningWasteEvaluationDataComRespDto_1 != null) {
            retData.setCleaningWasteEvaluationDataList(implementCleaningWasteEvaluationDataComRespDto_1.getCleaningWasteEvaluationDataList());//list-field-assign//sourceId:1120427_1
        }


        return retData;
    }
    //
}
